雖然我們使用firebase可以幫我們做到後端大部分的事情,但還是需要規劃資料結構,為什麼標題會有個ver.1,那表示這個版本不是最終版本,之後有發生寫到一半改結構的慘事...
初期我們雖然有畫出手繪的ER圖,但實在不知道怎麼把這圖對應到firebase上,此時有人建議我們用巢狀陣列的方式,試著寫寫看覺得滿合理的啊~就決定採用這個結構
{
"stores": { //店家資訊
"-L05fjkdfjkdjfa": {
"storeID": "1",
"storeName": "XX便當",
"phone": "04-1234567",
"address": "台中市台灣大道2段xX號",
"openTime": "09:00",
"closeTime": "20:00",
"deliveryCondition": "訂三個便當以上",
"storeType": "中式",
"menuImage": "img/XX便當.jpg"
}
},
"dishes": { //菜單
"-L05fnvmcvmz;": {
"dishID": "1",
"dishName": "排骨便當",
"storeID": "1",
"price": "30"
}
},
"orders": { //團訂資訊
"-L05anvmctuirpwool": {
"orderID": "001",
"orderEndTime": "2017/12/13-10:30:00",
"storeID": "1",
"total": 500,
"active": true,
"members": [
{
"userID": "user1",
"name": "Clover",
"order": [
{
"dishID": "1",
"count": "1",
"subtotal": 30
},
{
"dishID": "2",
"count": "10",
"subtotal": 30
}
],
"userTotal": 60
}
]
}
}
}